package com.yvan.example;

import com.p6spy.engine.common.P6Util;
import com.p6spy.engine.spy.appender.MessageFormattingStrategy;

public class P6SpyLogger implements MessageFormattingStrategy {
    @Override
    public String formatMessage(int connectionId, String now, long elapsed,
                                String category, String prepared, String sql, String url) {
//        return !"".equals(sql.trim()) ? "| took "
//                + elapsed + "ms | " + category + " | connection " + connectionId + "\n "
//                + P6Util.singleLine(sql) + ";" : "";
        // return sql;
        if ("commit".equals(category)) {
            return "cost " + elapsed + "ms - " + category + " - c:" + connectionId;
        }

        return "cost " + elapsed + "ms - " + category + " - c:" + connectionId + "\n" +
                //"RAW: " + P6Util.singleLine(prepared) + "\n" +
                P6Util.singleLine(sql);
    }
}
